#include "LoadingScene.h"



LoadingScene::LoadingScene()
{
	_startTime=GetTickCount();
	_playerLife=0;
}

LoadingScene::LoadingScene(int playerlife)
{
	_startTime=GetTickCount();
	_playerLife=playerlife;
}

LoadingScene::~LoadingScene()
{
}




void LoadingScene::Update(float DeltaTime)
{
	float delta=GetTickCount()-_startTime;
	if(delta>=3000)
	{
		SceneManager::GetInstance()->PopScene();

	}	

}

void LoadingScene::Render()
{
	ResourceManager *_ResourceManager=ResourceManager::GetInstance();

	

	/*_ResourceManager->GetSurface(_ResourceManager->SurfaceName.PauseScene_Background)->Draw(_backBuffer,NULL,NULL);*/
	ResourceManager::GetInstance()->GetSurface(ResourceManager::GetInstance()->SurfaceName.Background)->Draw(_backBuffer, NULL, NULL );
	
	RECT rect;
	rect.left=33.4*3;
	rect.top=0;
	rect.right=rect.left+33.4;
	rect.bottom=rect.top+64;
	_spriteHandler->Draw(_ResourceManager->GetTexture(_ResourceManager->TextureName.Mario)->Get_Texture(),&rect,0,&D3DXVECTOR3(300,250,0),D3DCOLOR_XRGB(253, 253, 253));
	
	ID3DXFont *g_font=NULL;

	HRESULT hr;

   hr=D3DXCreateFont(_d3ddv,     //D3D Device

                     35,               //Font height

                     0,                //Font width

                     FW_NORMAL,        //Font Weight

                     1,                //MipLevels

                     false,            //Italic

                     DEFAULT_CHARSET,  //CharSet

                     OUT_DEFAULT_PRECIS, //OutputPrecision

                     ANTIALIASED_QUALITY, //Quality

                     DEFAULT_PITCH|FF_DONTCARE,//PitchAndFamily

                     L"Tahoma",          //pFacename,

                     &g_font);         //ppFont

   
   RECT font_rect1;
   font_rect1.left=400;
   font_rect1.top=260;
   font_rect1.right=font_rect1.left+150;
   font_rect1.bottom=font_rect1.top+150;

    RECT font_rect2;
   font_rect2.left=450;
   font_rect2.top=260;
   font_rect2.right=font_rect2.left+150;
   font_rect2.bottom=font_rect2.top+150;

   tstringstream stros;
   stros << _playerLife; 
  

   g_font->DrawText(_spriteHandler,        //pSprite

								L"X ",  //pString

								1,          //Count

                                &font_rect1,  //pRect

                                DT_LEFT|DT_NOCLIP,//Format,

                                0xFFFFFFFF); //Color

	g_font->DrawText(_spriteHandler,        //pSprite

								(LPCWSTR)stros.str().c_str(),  //pString

								stros.str().size(),          //Count

                                &font_rect2,  //pRect

                                DT_LEFT|DT_NOCLIP,//Format,

                                0xFFFFFFFF); //Color
}

void LoadingScene::Leave()
{
	// Giai phong bo nho

	
}

void LoadingScene::Pause()
{
	// Tam thoi ngung hoat dong
}

void LoadingScene::Resume()
{
	// Tai hoat dong
}
